package ils.services;

import ils.domain.catalog.model.Book;
import ils.util.HibernateSession;
import ils.util.HibernateSessionManager;
import ils.util.SpringUtil;
import ils.util.Util;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: rejeevd
 * Date: 7/10/12
 * Time: 11:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class CatalogServiceTest
{
    ApplicationContext context = SpringUtil.getApplicationContext();
    CatalogService catalogService = (CatalogService)context.getBean("catalogService");

    @Test
    public void testAddBook()
    {
        Book book = new Book();
        book.setAuthor(Util.randomString(10));
        book.setTitle(Util.randomString(15));
        book.setDescription("this is created by integration test");
        book.setCategoryId(8);
        book = catalogService.addBook(book);
        Assert.assertNotNull(book.getId());
    }
}
